<?php

namespace App\Http\Controllers\Admin;

use App\Filters\CategoryFilter;
use App\Http\Controllers\Controller;
use App\Services\CategoryService;
use Illuminate\Http\Request;

/**
 * Copyright (C), 2021-2021, old_liu_cms.
 * FileName: ${FILE_NAME}
 * Description: 说明
 *
 * @author head_img
 * @Create Date    2021/10/10 14:09
 * @Update Date    2021/10/10 14:09 By head_img
 * @version v1.0
 */
class CategoryController extends Controller
{
    protected $service;
    protected $request;

    /**
     * AuthController constructor.
     * @param CategoryService $service
     * @param Request $request
     */
    public function __construct(CategoryService $service,Request $request)
    {
        $this->service = $service;
        $this->request = $request;
    }


    /**
     * FunctionName：store
     * Description：创建
     * Author：lwl
     * @return mixed
     */
    public function store()
    {
        return $this->service->store($this->request->input());
    }

    /**
     * FunctionName：lists
     * Description：列表
     * Author：lwl
     * @return \Illuminate\Database\Eloquent\Builder[]|\Illuminate\Database\Eloquent\Collection
     */
   public function lists(CategoryFilter $filter)
   {
       return $this->service->lists($filter);
   }

    /**
     * FunctionName：show
     * Description：详情
     * Author：lwl
     * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model|object|null
     */
    public function show()
    {
        return $this->service->show($this->request->input('id'));
    }

    /**
     * FunctionName：edit
     * Description：更细
     * Author：lwl
     * @return int
     */
    public function edit()
    {
        return $this->service->edit($this->request->only(['title','href','id']));
    }

    /**
     * FunctionName：remove
     * Description：删除
     * Author：lwl
     * @return int
     */
    public function remove()
    {
        return $this->service->remove($this->request->input('id'));
    }
}
